package ru.vsu.cs.brainsaver.game;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;

public class Zombie 
{
	private Bitmap pic;
	Rectangle mRect;
	int posX;
	int posY;
	boolean dead;
	Brain b;
	

	public void init(Bitmap pict,Brain b,int Y)
	{
		dead=false;
		this.pic=pict;
		posX=0;
		posY=Y;
		mRect = new Rectangle(posX,posY-pic.getHeight(),pic.getWidth(),pic.getHeight());
		this.b=b;
	}
	
	public void Update(int x,int y,int width, int heigth)
	{
		mRect.x+=1;
		if (mRect.contains(x, y, width, heigth))
		{
			dead=true;
			b.life--;
		}
	}
	
	public void Draw(Canvas canvas,Paint cPaint)
	{
		if(!dead)
		{
			canvas.drawBitmap(pic, mRect.x, mRect.y, cPaint);
		}
	}

}
